package com.secf.service.action.hpy.hys.ListDir;

import java.util.Arrays;

/**
 * @Author ms
 * @Date 2024-07-31 11:26
 */
public class Test5 {
    public static void main(String[] args) {
        int[] numbers = {3, 1, 4, 1, 5};

        // 排序数组
        System.out.println("原始数组: " + Arrays.toString(numbers));
        Arrays.sort(numbers);
        System.out.println("排序后的数组: " + Arrays.toString(numbers));

        // 查找元素
        int target = 4;
        int index = Arrays.binarySearch(numbers, target);
        if (index < 0) {
            System.out.println("元素 " + target + " 未找到");
        } else {
            System.out.println("元素 " + target + " 的位置: " + index);
        }
    }
}
